<template>
  <div class="login">
    <div class="ctx">
      <div class="form_out">
          <el-input placeholder="请输入账号" prefix-icon="el-icon-user" v-model="user"/>
      </div>
      <div class="form_out">
          <el-input placeholder="请输入密码" prefix-icon="el-icon-lock" v-model="pwd"/>
      </div>  
      <div class="form_out">
          <el-button  type="primary" @click="loginIn">登录</el-button>
      </div>  
    </div>
    
  </div>
</template>
<script>
export default {
  data(){
    // 定义数据
    return {
      user:'',
      pwd:''
    }
  },
  methods:{
    loginIn(){

        const {user,pwd} = this;
        
        // 非空校验
        // 正则校验
        
        this.$httpAxios(this.$api.ADMIN_LOGIN({user,pwd}),res=>{
          localStorage.user = user
          this.$router.push('/home')
        })
    }
  }
}
</script>
<style>
.login{
  background: rgb(249, 248, 248) 100%;
  height: 100vh;
  width: 100vw;
}

.ctx{
  width: 300px;
  height: 180px;
  background: #fff;
  position: fixed;
  top:0;
  margin: auto;
  bottom:0;
  left: 0;
  right: 0;
  padding: 10px;
}

.form_out{
   padding: 10px;
}
.form_out .el-button{
  width: 100%;
}
</style>